﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.OfficeDocument;
using Enterprise.Service.OfficeDocument;
namespace Enterprise.UI.Web.Modules.OfficeDocument
{
    public partial class Detail : System.Web.UI.Page
    {
        protected string Id = (string)Utility.sink("ODID", Utility.MethodType.Get, 0, 0, Utility.DataType.Str);
        protected string NavString = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
                OnRefreshRecevie();
            }
        }

        private void OnStart()
        {
            OnInit();
        }

        private void OnInit()
        {
            OfficeDocService odService=new OfficeDocService();
            var query = odService.OfficeDocumentDisp(Id);
            if (query != null)
            {
                lb_Type.Text = query.ODTYPE;
                lb_Code.Text = query.ODCODE;
                lb_Name.Text = query.ODCNAME;
                lb_RName.Text = query.ODRNAME;
                lb_Content.Text = query.ODCREMARK;
                lb_RContent.Text = query.ODRREMARK;
                lb_Files.Text = query.ODFILES;
            }
        }

        /// <summary>
        /// 绑定签收人
        /// </summary>
        private void OnRefreshRecevie()
        {
            OfficeRecevieService arService = new OfficeRecevieService();
            if (!arService.OfficeRecevieCheck(Id, Utility.Get_UserId))
            {
                OfficeRecevieEntity entity = new OfficeRecevieEntity();
                entity.OID = Id;
                entity.ORUSERID = Utility.Get_UserId;
                entity.ORTIME = DateTime.Now;
                entity.DB_Option_Action = "Insert";
                arService.OfficeRecevieExecute(entity);
            }
        }

    }
}